﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Unity;
using Vit.Web.Models;
using Vit.Common.Extensions;

namespace Vit.Web.Services
{
    public class LogService : ILogService
    {
        private IUnityContainer unity;
        private IEnumerable<ILogProvider> providers;

        public LogService(IUnityContainer unity)
        {
            this.unity = unity;
        }

        public IEnumerable<ILogProvider> Providers
        {
            get
            {
                if (providers == null || providers.Count() <= 0)
                {
                    providers = unity.ResolveAll<ILogProvider>();
                }
                return providers;
            }
        }

        public void Info(string category, object obj)
        {
            Providers.ForEach((o, i) => o.Info(category, obj));
        }

        public void Info(string category, string message)
        {
            Providers.ForEach((o, i) => o.Info(category, message));
        }

        public void Info(string category, string message, params object[] args)
        {
            Providers.ForEach((o, i) => o.Info(category, message, args));
        }

        public void Info(string category, IFormatProvider formatProvider, object obj)
        {
            Providers.ForEach((o, i) => o.Info(category, formatProvider, obj));
        }

        public void Info(string category, IFormatProvider formatProvider, string message, params object[] args)
        {
            Providers.ForEach((o, i) => o.Info(category, formatProvider, message, args));
        }


        public void Debug(string category, object obj)
        {
            Providers.ForEach((o, i) => o.Info(category, obj));
        }

        public void Debug(string category, string message)
        {
            Providers.ForEach((o, i) => o.Info(category, message));
        }

        public void Debug(string category, string message, params object[] args)
        {
            Providers.ForEach((o, i) => o.Info(category, message, args));
        }

        public void Debug(string category, IFormatProvider formatProvider, object obj)
        {
            Providers.ForEach((o, i) => o.Info(category, obj));
        }

        public void Debug(string category, IFormatProvider formatProvider, string message, params object[] args)
        {
            Providers.ForEach((o, i) => o.Info(category, formatProvider, message, args));
        }


        public void Error(string category, object obj)
        {
            Providers.ForEach((o, i) => o.Info(category, obj));
        }

        public void Error(string category, string message)
        {
            Providers.ForEach((o, i) => o.Info(category, message));
        }

        public void Error(string category, string message, params object[] args)
        {
            Providers.ForEach((o, i) => o.Info(category, message, args));
        }

        public void Error(string category, IFormatProvider formatProvider, object obj)
        {
            Providers.ForEach((o, i) => o.Info(category, obj));
        }

        public void Error(string category, IFormatProvider formatProvider, string message, params object[] args)
        {
            Providers.ForEach((o, i) => o.Info(category, formatProvider, message, args));
        }


        public void Fatal(string category, object obj)
        {
            Providers.ForEach((o, i) => o.Info(category, obj));
        }

        public void Fatal(string category, string message)
        {
            Providers.ForEach((o, i) => o.Info(category, message));
        }

        public void Fatal(string category, string message, params object[] args)
        {
            Providers.ForEach((o, i) => o.Info(category, message, args));
        }

        public void Fatal(string category, IFormatProvider formatProvider, object obj)
        {
            Providers.ForEach((o, i) => o.Info(category, formatProvider, obj));
        }

        public void Fatal(string category, IFormatProvider formatProvider, string message, params object[] args)
        {
            Providers.ForEach((o, i) => o.Info(category, formatProvider, message, args));
        }


        public void Trace(string category, object obj)
        {
            Providers.ForEach((o, i) => o.Info(category, obj));
        }

        public void Trace(string category, string message)
        {
            Providers.ForEach((o, i) => o.Info(category, message));
        }

        public void Trace(string category, string message, params object[] args)
        {
            Providers.ForEach((o, i) => o.Info(category, message, args));
        }

        public void Trace(string category, IFormatProvider formatProvider, object obj)
        {
            Providers.ForEach((o, i) => o.Info(category, formatProvider, obj));
        }

        public void Trace(string category, IFormatProvider formatProvider, string message, params object[] args)
        {
            Providers.ForEach((o, i) => o.Info(category, formatProvider, message, args));
        }


        public void Warn(string category, object obj)
        {
            Providers.ForEach((o, i) => o.Info(category, obj));
        }

        public void Warn(string category, string message)
        {
            Providers.ForEach((o, i) => o.Info(category, message));
        }

        public void Warn(string category, string message, params object[] args)
        {
            Providers.ForEach((o, i) => o.Info(category, message, args));
        }

        public void Warn(string category, IFormatProvider formatProvider, object obj)
        {
            Providers.ForEach((o, i) => o.Info(category, formatProvider, obj));
        }

        public void Warn(string category, IFormatProvider formatProvider, string message, params object[] args)
        {
            Providers.ForEach((o, i) => o.Info(category, formatProvider, message, args));
        }

    }
}
